package com.et.core.goods

import android.os.Environment
import android.util.Log
import androidx.test.platform.app.InstrumentationRegistry
import com.et.core.store.DataBaseUtil
import com.et.logger.TAGS
import com.et.util.deleteFile
import org.junit.Before
import org.junit.Test

class GoodsMergeKtTest {

    @Before
    fun setUp() {
        InstrumentationRegistry.getInstrumentation().context?.apply {
            Environment.getExternalStoragePublicDirectory("database")?.also {
                it.deleteFile()
                DataBaseUtil.init(this)
                GoodsHelper.getInstance().cat()
            }
        }
    }

    @Test
    fun goodsUpdate() {
        Log.d(TAGS.vending, "start test")
        val json =
            "{\"data\":[{\"rtime\":\"\",\"issend\":\"\",\"goodsID\":\"03\",\"kind\":\"\",\"count\":0,\"type\":\"\",\"ele_2\":\"\",\"ele_1\":\"\",\"road\":\"01\",\"price\":\"00010\",\"avm\":\"10000000\",\"ctime\":\"\",\"lock\":\"\",\"share\":\"\",\"barcode\":\"010002\",\"guihao\":\"09\",\"username\":\"\"},{\"rtime\":\"\",\"issend\":\"\",\"goodsID\":\"03\",\"kind\":\"\",\"count\":0,\"type\":\"\",\"ele_2\":\"\",\"ele_1\":\"\",\"road\":\"02\",\"price\":\"00010\",\"avm\":\"10000000\",\"ctime\":\"\",\"lock\":\"\",\"share\":\"\",\"barcode\":\"010002\",\"guihao\":\"09\",\"username\":\"\"}],\"avm\":\"10000000\",\"goods\":[{\"islock\":\"0\",\"picUrl\":\"https://pic1.zhimg.com/v2-6d285bc8a02ffdbb2a26ce60ea87ba38_1440w.jpg?source=172ae18b\",\"unit\":null,\"prodataMd5\":\"7af8cb401df6b77335321bcabaf8ec1b\",\"price\":\"\",\"name\":\"Sleekcan七喜莫7托[西柚]\",\"days\":111,\"pic\":\"0BKh95sKSnjwo5DPNMD7YEw7jNr3WtlQ.png\",\"type\":\"2\",\"barcode\":\"010002\",\"spec\":null}],\"time\":\"20210811131307\",\"type\":\"05\"}"
        goodsUpdate(json)
    }
}